<div class="modal fade" id="userPassword" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">修改密码</h4>
            </div>
            <div class="modal-body">
                <div class="panel-body">
                    <form class="panel-body form-horizontal form-padding">
                        <div class="form-group">
                            <label class="col-md-3 control-label" for="demo-text-input">新密码</label>
                            <div class="col-md-6">
                                <input type="password" id="newPassword" name="newPassword" value="" class="form-control" placeholder="请输入新密码">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label" for="demo-text-input">确认密码</label>
                            <div class="col-md-6">
                                <input type="password" id="passwordAgain" name="passwordAgain" value="" class="form-control" placeholder="请再次输入密码">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-3 control-label" for="demo-text-input"></label>
                            <div class="col-md-6">
                                <button type="button" class="btn btn-success" onclick="updatePassword()">保存</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <div class="modal-footer">
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function updatePassword() {
        var newPassword = $.trim($("#newPassword").val());
        if (newPassword == null || newPassword == "") {
            alert("请输入新密码。");
            return false;
        }
        var passwordAgain = $.trim($("#passwordAgain").val());
        if (passwordAgain != newPassword) {
            alert("请保持验证密码和新密码一致。");
            return false;
        }
        $.post("<@spring.url "/updatePassword"/>",{
            newPassword:newPassword}, function (data) {
            if (data.code==1) {
                alert(data.message);
                if (data.code == 1){
                    $("#userPassword").modal("hide");
                }
            }
        });
    }
</script>